﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Cms.Application.WebFramework.Presenters;
using Cms.Application.WebFramework.Views;
using Cms.Domain;
using iLib.Web.UI;
using Page = System.Web.UI.Page;

namespace Cms.Web.Framework.Infrastructure
{
    public class RssHandler : Page, IRssHandlerView
    {
        private RssHandlerPresenter _presenter;
        private RequestDetails _requestDetails;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _requestDetails = (RequestDetails)HttpContext.Current.Items["RequestDetails"];
            _presenter = new RssHandlerPresenter(this);
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/rss+xml";
            Response.Write(_presenter.GetRssFeedXml());
            Response.End();
        }

        public int UserId
        {
            get { throw new NotImplementedException(); }
        }

        public new Site Site
        {
            get { return _requestDetails.Site; }
        }

        public Locale Locale
        {
            get { return _requestDetails.Locale; }
        }

        public string Filename
        {
            get { return Request.QueryString["feed"]; }
        }
    }
}
